import { Connect } from './connect';
import mongoose = require('mongoose');
global.Promise = require("q").Promise;
mongoose.Promise = global.Promise;

//程序入口函数
function main(args:Array<string>):void
{
    if(args.length > 2)//处理启动参数
    {
        
    }
    console.log('main...');
    let ip = '47.92.111.83';
    let port = '27017';
    entr.init({ip:ip,port:port});
}

class Entrance
{
    private _con:Connect;
    private _ip:string;
    private _port:string;

    constructor()
    {
        this._con = new Connect();
    }

    public init(args):void
    {
        this._ip = args.ip;
        this._port = args.port;
        let url = this._ip + ':' + this._port;
        let auth = "dbserver:dbserver";
        let acc = 'account';
        this._con.connectByUrl(auth + '@' + url + '/' + acc,acc);

        let games = 'games';
        this._con.connectByUrl(auth + '@' + url + '/' + games,games);
    }
}


var entr = new Entrance();
main(process.argv);